package org.wu.acw.server.application.impl;

import org.wu.framework.lazy.orm.web.plus.stereotype.LazyApplication;
import org.wu.acw.server.application.AcwSingleTableOperationLogApplication;
import org.wu.framework.web.response.Result;
import org.wu.acw.server.domain.model.acw.single.table.operation.log.AcwSingleTableOperationLog;
import org.wu.acw.server.application.command.acw.single.table.operation.log.AcwSingleTableOperationLogRemoveCommand;
import org.wu.acw.server.application.command.acw.single.table.operation.log.AcwSingleTableOperationLogStoryCommand;
import org.wu.acw.server.application.command.acw.single.table.operation.log.AcwSingleTableOperationLogUpdateCommand;
import org.wu.acw.server.application.command.acw.single.table.operation.log.AcwSingleTableOperationLogQueryListCommand;
import org.wu.acw.server.application.command.acw.single.table.operation.log.AcwSingleTableOperationLogQueryOneCommand;
import org.wu.acw.server.application.assembler.AcwSingleTableOperationLogDTOAssembler;
import org.wu.acw.server.application.dto.AcwSingleTableOperationLogDTO;
import java.util.stream.Collectors;
import jakarta.annotation.Resource;
import org.wu.acw.server.domain.model.acw.single.table.operation.log.AcwSingleTableOperationLogRepository;
import java.util.List;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
/**
 * describe 单表操作日志 
 *
 * @author Jia wei Wu
 * @date 2024/04/29 09:55 上午
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyApplicationImpl 
 **/
@LazyApplication
public class AcwSingleTableOperationLogApplicationImpl implements AcwSingleTableOperationLogApplication {

    @Resource
    AcwSingleTableOperationLogRepository acwSingleTableOperationLogRepository;
    /**
     * describe 新增单表操作日志
     *
     * @param acwSingleTableOperationLogStoryCommand 新增单表操作日志     
     * @return {@link Result<AcwSingleTableOperationLog>} 单表操作日志新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2024/04/29 09:55 上午
     **/

    @Override
    public Result<AcwSingleTableOperationLog> story(AcwSingleTableOperationLogStoryCommand acwSingleTableOperationLogStoryCommand) {
        AcwSingleTableOperationLog acwSingleTableOperationLog = AcwSingleTableOperationLogDTOAssembler.INSTANCE.toAcwSingleTableOperationLog(acwSingleTableOperationLogStoryCommand);
        return acwSingleTableOperationLogRepository.story(acwSingleTableOperationLog);
    }
    /**
     * describe 批量新增单表操作日志
     *
     * @param acwSingleTableOperationLogStoryCommandList 批量新增单表操作日志     
     * @return {@link Result<List<AcwSingleTableOperationLog>>} 单表操作日志新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/04/29 09:55 上午
     **/

    @Override
    public Result<List<AcwSingleTableOperationLog>> batchStory(List<AcwSingleTableOperationLogStoryCommand> acwSingleTableOperationLogStoryCommandList) {
        List<AcwSingleTableOperationLog> acwSingleTableOperationLogList = acwSingleTableOperationLogStoryCommandList.stream().map( AcwSingleTableOperationLogDTOAssembler.INSTANCE::toAcwSingleTableOperationLog).collect(Collectors.toList());
        return acwSingleTableOperationLogRepository.batchStory(acwSingleTableOperationLogList);
    }
    /**
     * describe 更新单表操作日志
     *
     * @param acwSingleTableOperationLogUpdateCommand 更新单表操作日志     
     * @return {@link Result<AcwSingleTableOperationLog>} 单表操作日志领域对象     
     
     * @author Jia wei Wu
     * @date 2024/04/29 09:55 上午
     **/

    @Override
    public Result<AcwSingleTableOperationLog> updateOne(AcwSingleTableOperationLogUpdateCommand acwSingleTableOperationLogUpdateCommand) {
        AcwSingleTableOperationLog acwSingleTableOperationLog = AcwSingleTableOperationLogDTOAssembler.INSTANCE.toAcwSingleTableOperationLog(acwSingleTableOperationLogUpdateCommand);
        return acwSingleTableOperationLogRepository.story(acwSingleTableOperationLog);
    }

    /**
     * describe 查询单个单表操作日志
     *
     * @param acwSingleTableOperationLogQueryOneCommand 查询单个单表操作日志     
     * @return {@link Result<AcwSingleTableOperationLogDTO>} 单表操作日志DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/04/29 09:55 上午
     **/

    @Override
    public Result<AcwSingleTableOperationLogDTO> findOne(AcwSingleTableOperationLogQueryOneCommand acwSingleTableOperationLogQueryOneCommand) {
        AcwSingleTableOperationLog acwSingleTableOperationLog = AcwSingleTableOperationLogDTOAssembler.INSTANCE.toAcwSingleTableOperationLog(acwSingleTableOperationLogQueryOneCommand);
        return acwSingleTableOperationLogRepository.findOne(acwSingleTableOperationLog).convert(AcwSingleTableOperationLogDTOAssembler.INSTANCE::fromAcwSingleTableOperationLog);
    }

    /**
     * describe 查询多个单表操作日志
     *
     * @param acwSingleTableOperationLogQueryListCommand 查询多个单表操作日志     
     * @return {@link Result<List<AcwSingleTableOperationLogDTO>>} 单表操作日志DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/04/29 09:55 上午
     **/

    @Override
    public Result<List<AcwSingleTableOperationLogDTO>> findList(AcwSingleTableOperationLogQueryListCommand acwSingleTableOperationLogQueryListCommand) {
        AcwSingleTableOperationLog acwSingleTableOperationLog = AcwSingleTableOperationLogDTOAssembler.INSTANCE.toAcwSingleTableOperationLog(acwSingleTableOperationLogQueryListCommand);
        return acwSingleTableOperationLogRepository.findList(acwSingleTableOperationLog)        .convert(acwSingleTableOperationLogs -> acwSingleTableOperationLogs.stream().map(AcwSingleTableOperationLogDTOAssembler.INSTANCE::fromAcwSingleTableOperationLog).collect(Collectors.toList())) ;
    }

    /**
     * describe 分页查询多个单表操作日志
     *
     * @param acwSingleTableOperationLogQueryListCommand 分页查询多个单表操作日志     
     * @return {@link Result<LazyPage<AcwSingleTableOperationLogDTO>>} 分页单表操作日志DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/04/29 09:55 上午
     **/

    @Override
    public Result<LazyPage<AcwSingleTableOperationLogDTO>> findPage(int size,int current,AcwSingleTableOperationLogQueryListCommand acwSingleTableOperationLogQueryListCommand) {
        AcwSingleTableOperationLog acwSingleTableOperationLog = AcwSingleTableOperationLogDTOAssembler.INSTANCE.toAcwSingleTableOperationLog(acwSingleTableOperationLogQueryListCommand);
        return acwSingleTableOperationLogRepository.findPage(size,current,acwSingleTableOperationLog)        .convert(page -> page.convert(AcwSingleTableOperationLogDTOAssembler.INSTANCE::fromAcwSingleTableOperationLog))            ;
    }

    /**
     * describe 删除单表操作日志
     *
     * @param acwSingleTableOperationLogRemoveCommand 删除单表操作日志     
     * @return {@link Result<AcwSingleTableOperationLog>} 单表操作日志     
     
     * @author Jia wei Wu
     * @date 2024/04/29 09:55 上午
     **/

    @Override
    public Result<AcwSingleTableOperationLog> remove(AcwSingleTableOperationLogRemoveCommand acwSingleTableOperationLogRemoveCommand) {
     AcwSingleTableOperationLog acwSingleTableOperationLog = AcwSingleTableOperationLogDTOAssembler.INSTANCE.toAcwSingleTableOperationLog(acwSingleTableOperationLogRemoveCommand);
     return acwSingleTableOperationLogRepository.remove(acwSingleTableOperationLog);
    }

}